package com.lyubia.shop.portal.controller;

import com.lyubia.shop.api.service.SearchService;
import com.lyubia.shop.api.vo.GoodsVo;
import com.lyubia.shop.common.result.ShopPageInfo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;


@Controller
@RequestMapping("/search")
public class SearchController {

    @Reference(version = "1.0")
    private SearchService searchService;

    @GetMapping("/index")
    public String index(String searchStr, Model model) {
        model.addAttribute("searchStr",searchStr);
        return "search";
    }

    @GetMapping("/searchGoods")
    @ResponseBody
    public ShopPageInfo<GoodsVo> searchGoods(String searchStr, Integer pageNum, Integer pageSize) {
        return searchService.doSearch(searchStr, pageNum, pageSize);
    }

}
